<?php
class boss_data extends db 
{
	public function __construct()
	{
		parent::__construct();
		
	}
	
	protected function getAllBossList()
	{
		$this->query("SELECT b.bossid as id, b.bossname, i.istancename, b.bosshp, b.bossstatus FROM boss as b, istance as i WHERE b.istanceid = i.istanceid");
		
		if($this->num_rows())
		{
			return $this->fetch_all_row();
		}
		else 
			return null;		 
	}
	
	protected function setBoss()
	{
		if(isset($_POST['bossid']) and $_POST['bossid'] != null)
		{
			if(!$this->query("UPDATE boss SET
				istanceid = {$_POST['istanceid']},
				bossname = '{$_POST['bossname']}',
				bosshp = '{$_POST['bosshp']}',
				bossdesc = '{$_POST['bossdesc']}',
				bossstatus = '{$_POST['bossstatus']}',
				bossimage = '{$_POST['bossimage']}'
				WHERE bossid = {$_POST['bossid']}			
			"))
				return $this->error;
		}
		else
		{
			if(!$this->query("INSERT INTO boss SET
				istanceid = {$_POST['istanceid']},
				bossname = '{$_POST['bossname']}',
				bosshp = '{$_POST['bosshp']}',
				bossdesc = '{$_POST['bossdesc']}',
				bossstatus = '{$_POST['bossstatus']}',
				bossimage = '{$_POST['bossimage']}'
			"))
				return $this->error;
		}
	}
	
	protected function getBoss()
	{
		$this->query("SELECT * FROM boss WHERE bossid = {$_POST['bossid']}");
		return $this->fetch_array();
	}
	
	protected function deleteBoss()
	{
		if(!$this->query("DELETE FROM boss WHERE bossid = {$_POST['bossid']}"))
			return $this->error;
	}
}
?>